#include <stdio.h>
#include <string.h>

int main(void)
{
	FILE *fp = fopen("mcl/sym.txt", "r");

	char buf[1024];
	int len;

	printf("// Genreated by mcl/makesym.c, DOT NOT EDIT.\n");
	printf("//\n");
	printf("#ifndef MCL_SYM_MAP_H_\n");
	printf("#define MCL_SYM_MAP_H_\n");
	printf("\n");

	printf("#define SYM_MAP(_) \\\n");
	while (fgets(buf, sizeof(buf), fp) != NULL) {
		len = strlen(buf);

		if (buf[len - 1] == '\n') {
			len -= 1;
			buf[len] = 0;
		}

		if (len == 0)
			continue;

		char *space = strchr(buf, ' ');

		char const *symbol;
		char const *text;

		if (space == NULL) {
			symbol = buf;
			text = buf;
		} else {
			*space = 0;
			symbol = buf;
			text = space + 1;
		}

		printf("\t_(%s, \"%s\", %zu) \\\n", symbol, text, strlen(text));
	}

	printf("\n");
	printf("#endif\n");

	fclose(fp);
	return 0;
}
